﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm3.aspx.vb" Inherits="LecturerAppointmentSystem.WebForm3" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    
     <asp:MultiView ID ="AppointmentsMultiView" runat="server">
    <asp:View ID="LecturerView" runat="server">
    <asp:GridView ID="LecturerGridView" runat="server" AutoGenerateColumns="False"
        DataSourceID="LecturerCalendarDataSource" EnableModelValidation="True" 
            AllowSorting="True">
        <Columns>
            <asp:BoundField DataField="AppointmentDate" HeaderText="Date" 
                SortExpression="AppointmentDate" DataFormatString="{0:d}" />
            <asp:BoundField DataField="TimeSlot" HeaderText="Time" 
                SortExpression="TimeSlot" />
            <asp:BoundField DataField="Place" HeaderText="Place" SortExpression="Place" />
            <asp:TemplateField HeaderText="Booked By">
                <ItemTemplate>
                    <asp:Label ID="lbl_BookedBy" runat="server" Text='<%# parseBooked(Eval("Booked")) %>'></asp:Label>
                    <br />
                    <asp:LinkButton ID="linkButton_BookedBy" runat="server" Text=""></asp:LinkButton>
                </ItemTemplate>
                </asp:TemplateField>
            <asp:HyperLinkField DataNavigateUrlFields="ID" 
                DataNavigateUrlFormatString="AppointmentDetails.aspx?ID={0}" 
                Text="View Details" />
        </Columns>
    </asp:GridView>
    <br />
    <asp:Label ID="lblresult" runat="server" />
    <br />
    <asp:Button ID="btnShowAvailablePopup" runat="server" Style="display: none" />
    <br />
    <asp:ModalPopupExtender ID="AvailablePopup" runat="server" TargetControlID="btnShowAvailablePopup"
        PopupControlID="placePanel" CancelControlID="ButtonCancel">
    </asp:ModalPopupExtender>
    <asp:Panel ID="placePanel" runat="server" CssClass="modalPopupPanel">
        <asp:Label ID="lbl_TimeSlot" runat="server"></asp:Label>
        <asp:Label ID="placeLabel" runat="server" Text="Please enter the location for the appointment"></asp:Label>
        <asp:TextBox ID="tb_Place" runat="server"></asp:TextBox>
        <br />
        <br />
        <div style="text-align: right;">
            <asp:Button ID="ButtonSave" runat="server" Text="Save" CommandName="Save" OnClick="ButtonSave_Click" />
            <asp:Button ID="ButtonCancel" runat="server" Text="Cancel" />
        </div>
    </asp:Panel>
    <br />
    <asp:Button ID="btnShowUnavailablePopup" runat="server" Style="display: none" />
    <asp:ModalPopupExtender ID="UnavailablePopup" runat="server" TargetControlID="btnShowUnavailablePopup" PopupControlID="UnavailablePanel" CancelControlID="ButtonNo">
    </asp:ModalPopupExtender>
    <asp:Panel ID="UnavailablePanel" runat="server" CssClass="modalPopupPanel">
        <asp:Label ID="lbl_Unavailable" runat="server" Text="Are you sure you want to mark this slot as unavailable for an appointment?"></asp:Label>
        <br />
        <asp:Button ID="ButtonYes" runat="server" Text="Yes" CommandName="YesMarkAsUnavailable"
            OnClick="ButtonYes_Click" />
        <asp:Button ID="ButtonNo" runat="server" Text="No" />
    </asp:Panel>
    <br />
    <asp:Button ID="btnShowCancelBookedAppointmentPopup" runat="server" Style="display: none" />
    <br />
    <asp:ModalPopupExtender ID="CancelBookingPopup" runat="server" TargetControlID="btnShowCancelBookedAppointmentPopup"
        PopupControlID="CancelBookingPanel" CancelControlID="ButtonDoNotCancel">
     </asp:ModalPopupExtender>
    <asp:Panel ID="CancelBookingPanel" runat="server" CssClass="modalPopupPanel">
        <asp:Label ID="lbl_CancelBooking" runat="server" Text="Current slot already contains a booking. Please cancel the booking first."></asp:Label>
        <br />
        <br />
        <div style="text-align: right;">
            <asp:Button ID="ButtonOkCancel" runat="server" Text="Cancel Appointment" CommandName="CancelAppointment" OnClick="ButtonOkCancel_Click" />
            <asp:Button ID="ButtonDoNotCancel" runat="server" Text="Cancel" />
        </div>
    </asp:Panel>
    <asp:SqlDataSource ID="LecturerCalendarDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:AppointmentsConnectionString %>"
        ProviderName="<%$ ConnectionStrings:AppointmentsConnectionString.ProviderName %>"
        
            SelectCommand="SELECT * FROM [AppointmentsByLecturerQuery] WHERE ([Lecturer] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="Lecturer" QueryStringField="UserId" 
                Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <br />
    <br />
    <br />
    <%--<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2"
        EnableModelValidation="True" AllowSorting="True">
        <Columns>
            <asp:BoundField DataField="TimeSlot" HeaderText="TimeSlot" SortExpression="TimeSlot" />
            <asp:BoundField DataField="Place" HeaderText="Place" SortExpression="Place" />
            <asp:BoundField DataField="Agenda" HeaderText="Agenda" SortExpression="Agenda" />
            <asp:TemplateField HeaderText="Booked" SortExpression="Booked">
                <EditItemTemplate>
                    <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Booked") %>' />
                </EditItemTemplate>
                <ItemTemplate>
                    <%# Eval("Booked")%>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:AppointmentsConnectionString %>"
        ProviderName="<%$ ConnectionStrings:AppointmentsConnectionString.ProviderName %>"
        SelectCommand="SELECT TimeSlots.ID, TimeSlots.TimeSlot, derivedtbl_1.ID AS Expr1, derivedtbl_1.AppointmentDate, derivedtbl_1.Fkid_TimeSlot, derivedtbl_1.Place, derivedtbl_1.Agenda, derivedtbl_1.Booked, derivedtbl_1.Lecturer FROM (TimeSlots LEFT OUTER JOIN (SELECT ID, AppointmentDate, Fkid_TimeSlot, Place, Agenda, Booked, Lecturer FROM Appointments WHERE (AppointmentDate = ?) AND (Lecturer = ?)) derivedtbl_1 ON derivedtbl_1.Fkid_TimeSlot = TimeSlots.ID)">
        <SelectParameters>
            <asp:QueryStringParameter Name="?" QueryStringField="Date" />
            <asp:QueryStringParameter Name="?" QueryStringField="UserId" />
        </SelectParameters>
    </asp:SqlDataSource>--%>
    <br />
    </asp:View>
    <asp:View ID="StudentView" runat="server">
    
        <asp:GridView ID="StudentGridView" runat="server" AutoGenerateColumns="False"
        DataSourceID="StudentCalendarDataSource" EnableModelValidation="True" 
            AllowSorting="True">
            <Columns>
                <asp:BoundField DataField="AppointmentDate" HeaderText="Date" 
                    SortExpression="AppointmentDate" DataFormatString="{0:d}" />
                <asp:BoundField DataField="Fkid_TimeSlot" HeaderText="Time" 
                    SortExpression="Fkid_TimeSlot" />
                <asp:BoundField DataField="Place" HeaderText="Place" SortExpression="Place" />
                <asp:BoundField DataField="Lecturer" HeaderText="Lecturer" 
                    SortExpression="Lecturer" />
                <asp:HyperLinkField DataNavigateUrlFields="ID" 
                    DataNavigateUrlFormatString="AppointmentDetails.aspx?ID={0}" 
                    Text="View Details" />
            </Columns>
        </asp:GridView>
    
        <asp:SqlDataSource ID="StudentCalendarDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:AppointmentsConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:AppointmentsConnectionString.ProviderName %>" 
            SelectCommand="SELECT * FROM [BookedSlotsQuery] WHERE ([BookedBy] = ?)">
            <SelectParameters>
                <asp:QueryStringParameter Name="BookedBy" QueryStringField="UserId" 
                    Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
    
    </asp:View>
    <asp:View ID="AdministratorView" runat="server">
    
    </asp:View>
</asp:MultiView>
    </form>
</body>
</html>
